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

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

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

b = A("b")
n = B("n")
c = C("c")
d = C("d")
j = A("j")
k = B("k")

b.o = d
n.p = j
n.s = j
n.w = d
c.t = d
d.t = c
j.o = d
k.p = j
k.w = d
k.s = b
assert k.p.o.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
c = C("c")
d = C("d")
j = A("j")
k = B("k")

b.o = d
n.p = j
n.s = j
n.w = d
c.t = d
d.t = c
j.o = d
k.p = j
k.w = d
k.s = b
assert k.p.o.t.t.t.t.txt == "d"