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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: D = None
        self.t: C = None
        self.p: B = 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.o: B = None
        self.z: A = None
        self.t: D = None
        self.txt = txt

l = A("l")
j = B("j")
d = C("d")
b = D("b")
k = D("k")
a = B("a")
g = A("g")

l.o = d
j.x = k
j.w = b
j.t = d
j.p = a
d.r = g
b.o = a
b.z = l
b.t = k
k.o = j
k.z = g
k.t = b
a.x = k
a.w = k
a.t = d
a.p = j
g.o = d
assert d.r.o.r.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: D = None
        self.t: C = None
        self.p: B = 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.o: B = None
        self.z: A = None
        self.t: D = None
        self.txt = txt

l = A("l")
j = B("j")
d = C("d")
b = D("b")
k = D("k")
a = B("a")
g = A("g")

l.o = d
j.x = k
j.w = b
j.t = d
j.p = a
d.r = g
b.o = a
b.z = l
b.t = k
k.o = j
k.z = g
k.t = b
a.x = k
a.w = k
a.t = d
a.p = j
g.o = d
assert d.r.o.r.o.r.o.r.txt == "g"