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

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

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

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

l = A("l")
g = B("g")
d = C("d")
h = D("h")
f = B("f")
b = D("b")

l.o = d
l.r = f
g.p = h
g.o = h
g.v = l
d.y = b
d.z = b
d.x = b
h.s = d
h.y = b
f.p = h
f.o = h
f.v = l
b.s = d
b.y = h
assert l.o.y.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
d = C("d")
h = D("h")
f = B("f")
b = D("b")

l.o = d
l.r = f
g.p = h
g.o = h
g.v = l
d.y = b
d.z = b
d.x = b
h.s = d
h.y = b
f.p = h
f.o = h
f.v = l
b.s = d
b.y = h
assert l.o.y.s.z.txt == "b"