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

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: B = None
        self.w: B = None
        self.txt = txt

e = A("e")
m = B("m")
f = C("f")
g = D("g")
b = C("b")
d = B("d")

e.o = d
m.q = f
m.t = b
m.w = b
f.r = e
g.u = b
g.s = m
g.w = d
b.r = e
d.q = f
d.t = f
d.w = b
assert e.o.w.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: B = None
        self.w: B = None
        self.txt = txt

e = A("e")
m = B("m")
f = C("f")
g = D("g")
b = C("b")
d = B("d")

e.o = d
m.q = f
m.t = b
m.w = b
f.r = e
g.u = b
g.s = m
g.w = d
b.r = e
d.q = f
d.t = f
d.w = b
assert e.o.w.r.o.txt == "d"