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

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

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

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

c = A("c")
k = B("k")
b = C("b")
n = D("n")

c.y = k
k.t = n
k.u = b
k.y = b
b.v = k
n.t = b
n.o = k
n.v = k
assert b.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
b = C("b")
n = D("n")

c.y = k
k.t = n
k.u = b
k.y = b
b.v = k
n.t = b
n.o = k
n.v = k
assert b.v.t.t.txt == "b"