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

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

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

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

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

h.y = m
h.u = n
f.y = h
f.q = m
m.o = c
n.t = m
n.x = h
n.s = h
c.o = m
assert f.q.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.u: D = None
        self.txt = txt

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

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

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

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

h.y = m
h.u = n
f.y = h
f.q = m
m.o = c
n.t = m
n.x = h
n.s = h
c.o = m
assert f.q.o.o.o.o.txt == "m"