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

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

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

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

k = A("k")
b = B("b")
d = C("d")
i = D("i")
j = B("j")

k.r = d
k.u = d
k.x = b
b.u = i
b.v = i
b.s = j
d.v = i
d.x = i
i.r = k
j.u = i
j.v = i
j.s = b
assert b.v.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: B = None
        self.u: C = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
d = C("d")
i = D("i")
j = B("j")

k.r = d
k.u = d
k.x = b
b.u = i
b.v = i
b.s = j
d.v = i
d.x = i
i.r = k
j.u = i
j.v = i
j.s = b
assert b.v.r.u.txt == "d"