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

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

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

l = A("l")
f = B("f")
b = C("b")
j = C("j")
m = C("m")
k = A("k")

l.y = k
l.r = k
l.w = k
f.q = k
f.p = m
b.t = k
b.y = m
j.t = k
j.y = b
m.t = k
m.y = j
k.y = l
k.r = l
k.w = l
assert f.p.t.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.r: A = None
        self.w: A = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
b = C("b")
j = C("j")
m = C("m")
k = A("k")

l.y = k
l.r = k
l.w = k
f.q = k
f.p = m
b.t = k
b.y = m
j.t = k
j.y = b
m.t = k
m.y = j
k.y = l
k.r = l
k.w = l
assert f.p.t.y.w.y.txt == "l"