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

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

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

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

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

d.v = j
d.q = k
a.p = k
a.v = k
a.r = k
k.o = j
k.x = d
k.p = e
k.u = e
i.r = j
i.x = j
e.v = i
e.q = k
j.r = i
j.x = i
assert i.r.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

d.v = j
d.q = k
a.p = k
a.v = k
a.r = k
k.o = j
k.x = d
k.p = e
k.u = e
i.r = j
i.x = j
e.v = i
e.q = k
j.r = i
j.x = i
assert i.r.x.x.txt == "j"