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

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

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

m = A("m")
h = B("h")
d = C("d")
a = A("a")
k = B("k")
b = C("b")
f = A("f")
n = A("n")
l = C("l")

m.p = l
m.r = d
h.q = f
h.u = l
h.y = k
d.x = b
d.t = l
a.p = b
a.r = b
k.q = m
k.u = l
k.y = h
b.x = l
b.t = d
f.p = l
f.r = l
n.p = l
n.r = l
l.x = b
l.t = d
assert n.p.t.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: C = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
d = C("d")
a = A("a")
k = B("k")
b = C("b")
f = A("f")
n = A("n")
l = C("l")

m.p = l
m.r = d
h.q = f
h.u = l
h.y = k
d.x = b
d.t = l
a.p = b
a.r = b
k.q = m
k.u = l
k.y = h
b.x = l
b.t = d
f.p = l
f.r = l
n.p = l
n.r = l
l.x = b
l.t = d
assert n.p.t.t.x.t.txt == "d"