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

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

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

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

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

b.t = n
n.u = b
n.v = b
n.x = i
k.t = b
k.x = b
k.p = b
i.t = b
assert b.t.u.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

b.t = n
n.u = b
n.v = b
n.x = i
k.t = b
k.x = b
k.p = b
i.t = b
assert b.t.u.t.v.txt == "b"