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

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

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

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

b = A("b")
k = B("k")
m = C("m")
n = D("n")
a = B("a")
d = C("d")
c = D("c")
f = A("f")

b.s = f
k.p = c
k.u = a
m.y = a
m.w = d
m.t = b
m.p = f
n.z = f
n.o = d
a.p = c
a.u = k
d.y = a
d.w = m
d.t = f
d.p = b
c.z = b
c.o = d
f.s = b
assert f.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
m = C("m")
n = D("n")
a = B("a")
d = C("d")
c = D("c")
f = A("f")

b.s = f
k.p = c
k.u = a
m.y = a
m.w = d
m.t = b
m.p = f
n.z = f
n.o = d
a.p = c
a.u = k
d.y = a
d.w = m
d.t = f
d.p = b
c.z = b
c.o = d
f.s = b
assert f.s.s.s.s.s.txt == "b"