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

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

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

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

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

h.q = l
h.r = b
h.o = b
h.t = n
l.p = n
l.q = n
l.x = j
j.x = h
j.o = c
n.q = c
b.x = h
b.o = c
c.q = n
assert l.x.o.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: C = None
        self.o: C = None
        self.t: D = None
        self.txt = txt

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

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

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

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

h.q = l
h.r = b
h.o = b
h.t = n
l.p = n
l.q = n
l.x = j
j.x = h
j.o = c
n.q = c
b.x = h
b.o = c
c.q = n
assert l.x.o.q.q.txt == "c"