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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.u: A = None
        self.txt = txt

a = A("a")
l = B("l")
d = C("d")
h = C("h")
j = B("j")
i = B("i")
c = C("c")

a.r = h
a.q = h
a.t = j
l.v = d
l.r = a
l.q = a
d.r = a
d.u = a
d.z = h
h.r = a
h.u = a
h.z = c
j.v = c
j.r = a
j.q = a
i.v = h
i.r = a
i.q = a
c.r = a
c.u = a
c.z = d
assert j.q.t.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: B = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.u: A = None
        self.txt = txt

a = A("a")
l = B("l")
d = C("d")
h = C("h")
j = B("j")
i = B("i")
c = C("c")

a.r = h
a.q = h
a.t = j
l.v = d
l.r = a
l.q = a
d.r = a
d.u = a
d.z = h
h.r = a
h.u = a
h.z = c
j.v = c
j.r = a
j.q = a
i.v = h
i.r = a
i.q = a
c.r = a
c.u = a
c.z = d
assert j.q.t.v.r.txt == "a"