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

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

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

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

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

h.t = j
h.s = j
h.x = j
h.q = j
c.r = m
m.q = c
m.r = l
j.s = c
j.o = c
j.q = h
l.r = m
f.q = c
f.r = c
assert j.o.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: D = None
        self.x: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

h.t = j
h.s = j
h.x = j
h.q = j
c.r = m
m.q = c
m.r = l
j.s = c
j.o = c
j.q = h
l.r = m
f.q = c
f.r = c
assert j.o.r.q.txt == "c"