class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.v: A = None
        self.x: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

d = A("d")
b = B("b")
j = C("j")
g = D("g")
c = E("c")
l = F("l")
h = C("h")

d.p = c
b.z = d
b.o = c
j.y = c
j.s = b
g.o = b
c.p = j
c.u = j
c.v = d
c.x = g
l.q = d
h.y = c
h.s = b
assert l.q.p.p.y.p.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.v: A = None
        self.x: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

d = A("d")
b = B("b")
j = C("j")
g = D("g")
c = E("c")
l = F("l")
h = C("h")

d.p = c
b.z = d
b.o = c
j.y = c
j.s = b
g.o = b
c.p = j
c.u = j
c.v = d
c.x = g
l.q = d
h.y = c
h.s = b
assert l.q.p.p.y.p.s.z.txt == "d"