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

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: B = None
        self.r: C = None
        self.txt = txt

b = A("b")
k = B("k")
f = C("f")
a = D("a")
n = A("n")
e = C("e")

b.y = n
k.u = n
k.p = a
k.w = b
k.x = e
f.p = b
f.o = k
f.z = k
a.w = f
a.v = k
a.r = e
n.y = b
e.p = n
e.o = k
e.z = k
assert n.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: B = None
        self.r: C = None
        self.txt = txt

b = A("b")
k = B("k")
f = C("f")
a = D("a")
n = A("n")
e = C("e")

b.y = n
k.u = n
k.p = a
k.w = b
k.x = e
f.p = b
f.o = k
f.z = k
a.w = f
a.v = k
a.r = e
n.y = b
e.p = n
e.o = k
e.z = k
assert n.y.y.y.y.y.txt == "b"