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

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

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

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

k = A("k")
b = B("b")
l = C("l")
g = D("g")

k.u = b
b.y = k
l.s = b
l.r = b
l.p = g
g.v = l
assert k.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
l = C("l")
g = D("g")

k.u = b
b.y = k
l.s = b
l.r = b
l.p = g
g.v = l
assert k.u.y.u.txt == "b"