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

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.z: E = None
        self.t: F = None
        self.o: E = None
        self.q: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.y: E = None
        self.v: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: D = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.z: E = None
        self.t: F = None
        self.o: E = None
        self.q: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.y: E = None
        self.v: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: D = None
        self.txt = txt

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

h.y = d
l.y = b
a.p = b
a.t = b
a.z = g
a.o = g
a.q = l
d.t = g
d.y = g
d.v = g
g.q = h
g.s = h
b.s = h
b.u = d
assert b.s.y.t.txt == "g"