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

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

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

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

c = A("c")
b = B("b")
m = C("m")
j = D("j")
h = B("h")
e = C("e")
l = A("l")

c.t = e
c.x = j
b.s = m
b.o = c
b.y = c
b.w = j
m.p = j
m.t = c
m.q = b
j.t = c
h.s = m
h.o = c
h.y = c
h.w = j
e.p = j
e.t = c
e.q = h
l.t = m
l.x = j
assert j.t.t.q.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: D = None
        self.txt = txt

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

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

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

c = A("c")
b = B("b")
m = C("m")
j = D("j")
h = B("h")
e = C("e")
l = A("l")

c.t = e
c.x = j
b.s = m
b.o = c
b.y = c
b.w = j
m.p = j
m.t = c
m.q = b
j.t = c
h.s = m
h.o = c
h.y = c
h.w = j
e.p = j
e.t = c
e.q = h
l.t = m
l.x = j
assert j.t.t.q.w.t.txt == "c"