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

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

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

j = A("j")
g = B("g")
n = C("n")
d = B("d")
a = B("a")
f = C("f")
e = A("e")

j.u = f
g.q = j
g.t = e
g.v = a
n.r = j
n.y = j
d.q = e
d.t = e
d.v = a
a.q = j
a.t = j
a.v = g
f.r = j
f.y = j
e.u = f
assert g.t.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

j = A("j")
g = B("g")
n = C("n")
d = B("d")
a = B("a")
f = C("f")
e = A("e")

j.u = f
g.q = j
g.t = e
g.v = a
n.r = j
n.y = j
d.q = e
d.t = e
d.v = a
a.q = j
a.t = j
a.v = g
f.r = j
f.y = j
e.u = f
assert g.t.u.y.u.txt == "f"