class A:
    def __init__(self, txt: str):
        self.r: B = 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.u: B = None
        self.x: B = None
        self.o: B = None
        self.s: D = None
        self.txt = txt

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

m = A("m")
n = B("n")
g = C("g")
i = D("i")
j = A("j")

m.r = n
n.r = g
g.u = n
g.x = n
g.o = n
g.s = i
i.q = m
i.u = g
j.r = n
assert m.r.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = 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.u: B = None
        self.x: B = None
        self.o: B = None
        self.s: D = None
        self.txt = txt

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

m = A("m")
n = B("n")
g = C("g")
i = D("i")
j = A("j")

m.r = n
n.r = g
g.u = n
g.x = n
g.o = n
g.s = i
i.q = m
i.u = g
j.r = n
assert m.r.r.u.r.txt == "g"