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

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

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

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

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

i.t = n
n.x = c
n.s = b
n.p = i
n.w = i
c.q = i
c.r = i
c.o = j
d.w = c
d.t = c
d.y = j
d.o = b
b.x = c
b.s = n
b.p = i
b.w = i
j.w = c
j.t = c
j.y = d
j.o = b
assert c.q.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

i.t = n
n.x = c
n.s = b
n.p = i
n.w = i
c.q = i
c.r = i
c.o = j
d.w = c
d.t = c
d.y = j
d.o = b
b.x = c
b.s = n
b.p = i
b.w = i
j.w = c
j.t = c
j.y = d
j.o = b
assert c.q.t.x.txt == "c"