class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: A = None
        self.r: C = None
        self.txt = txt

e = A("e")
c = B("c")
d = C("d")
l = C("l")
g = A("g")
j = B("j")
f = B("f")
a = A("a")
i = B("i")

e.y = d
c.q = d
d.p = c
d.t = e
d.r = l
l.p = c
l.t = e
l.r = d
g.y = d
j.q = l
f.q = l
a.y = d
i.q = l
assert j.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: A = None
        self.r: C = None
        self.txt = txt

e = A("e")
c = B("c")
d = C("d")
l = C("l")
g = A("g")
j = B("j")
f = B("f")
a = A("a")
i = B("i")

e.y = d
c.q = d
d.p = c
d.t = e
d.r = l
l.p = c
l.t = e
l.r = d
g.y = d
j.q = l
f.q = l
a.y = d
i.q = l
assert j.q.t.y.txt == "d"