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

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

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

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

l = A("l")
g = B("g")
n = C("n")
j = D("j")
f = B("f")
e = D("e")

l.r = n
l.s = n
l.q = n
l.w = j
g.r = l
n.t = l
j.v = l
j.q = e
j.o = g
f.r = l
e.v = l
e.q = j
e.o = g
assert n.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: C = None
        self.w: D = None
        self.q: C = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
n = C("n")
j = D("j")
f = B("f")
e = D("e")

l.r = n
l.s = n
l.q = n
l.w = j
g.r = l
n.t = l
j.v = l
j.q = e
j.o = g
f.r = l
e.v = l
e.q = j
e.o = g
assert n.t.s.t.txt == "l"