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

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

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

b = A("b")
d = B("d")
n = C("n")
h = B("h")
l = C("l")

b.q = h
d.u = l
d.t = h
d.p = h
n.x = d
n.q = l
n.t = l
h.u = l
h.t = d
h.p = d
l.x = h
l.q = n
l.t = n
assert h.t.p.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
n = C("n")
h = B("h")
l = C("l")

b.q = h
d.u = l
d.t = h
d.p = h
n.x = d
n.q = l
n.t = l
h.u = l
h.t = d
h.p = d
l.x = h
l.q = n
l.t = n
assert h.t.p.u.x.txt == "h"