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

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

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

b = A("b")
h = B("h")
c = C("c")
m = A("m")
f = C("f")
a = B("a")
d = A("d")

b.s = c
b.p = a
h.q = f
h.t = f
c.q = f
c.y = f
c.s = a
m.s = c
m.p = a
f.q = c
f.y = c
f.s = a
a.q = c
a.t = c
d.s = f
d.p = a
assert m.s.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: B = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
c = C("c")
m = A("m")
f = C("f")
a = B("a")
d = A("d")

b.s = c
b.p = a
h.q = f
h.t = f
c.q = f
c.y = f
c.s = a
m.s = c
m.p = a
f.q = c
f.y = c
f.s = a
a.q = c
a.t = c
d.s = f
d.p = a
assert m.s.s.t.s.txt == "a"