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

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

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

h = A("h")
e = B("e")
j = C("j")
f = C("f")
m = A("m")
c = B("c")
d = B("d")

h.s = d
h.q = f
e.x = d
e.s = c
e.q = j
j.u = m
j.t = d
f.u = m
f.t = d
m.s = e
m.q = j
c.x = e
c.s = e
c.q = f
d.x = e
d.s = c
d.q = j
assert c.x.q.u.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
j = C("j")
f = C("f")
m = A("m")
c = B("c")
d = B("d")

h.s = d
h.q = f
e.x = d
e.s = c
e.q = j
j.u = m
j.t = d
f.u = m
f.t = d
m.s = e
m.q = j
c.x = e
c.s = e
c.q = f
d.x = e
d.s = c
d.q = j
assert c.x.q.u.q.t.txt == "d"