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

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

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

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

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

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

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

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

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

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

b.y = h
b.x = f
b.p = c
d.p = h
d.o = l
d.r = e
h.o = c
h.r = d
h.y = d
h.q = l
e.x = f
e.z = d
e.q = h
f.p = h
f.o = l
f.r = c
c.x = d
c.z = f
c.q = h
l.y = h
l.x = d
l.p = c
assert d.r.z.p.r.p.txt == "h"