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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.r: B = None
        self.txt = txt

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

m = A("m")
g = B("g")
d = C("d")
j = D("j")
f = E("f")
h = F("h")
b = D("b")

m.y = b
m.z = d
m.p = d
g.z = d
g.x = h
g.t = b
d.s = f
d.p = m
j.y = f
f.u = h
f.r = g
h.r = g
b.y = f
assert g.z.s.u.r.x.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.r: B = None
        self.txt = txt

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

m = A("m")
g = B("g")
d = C("d")
j = D("j")
f = E("f")
h = F("h")
b = D("b")

m.y = b
m.z = d
m.p = d
g.z = d
g.x = h
g.t = b
d.s = f
d.p = m
j.y = f
f.u = h
f.r = g
h.r = g
b.y = f
assert g.z.s.u.r.x.r.z.txt == "d"